using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using AgileFx.ORM;
using AgileFx.ORM.Providers.EntityViewProviders;

using projectNS = Debugging.Models;
using intermediateNS = Debugging.Models.Intermediate;
using L2SNS = Debugging.Models.L2S;

namespace Debugging.Models
{
	public class CustomerMapping : ModelEntityMapping<projectNS.Customer, intermediateNS.Customer, L2SNS.Customer, L2SNS.User>
	{
		public CustomerMapping() : base(e => e.User)
		{
			AddIdentityField<long>(e => e.Id); 
			AddRelationship<projectNS.Item>(e => e.Items, e => e.Customer);
		}
	}
		
	[ClassMapping(typeof(CustomerMapping))]
	public partial class Customer : User, IEntityView<intermediateNS.Customer>
	{
		private intermediateNS.Customer __intermediateEntity;
		public new intermediateNS.Customer _intermediateEntity { get { return __intermediateEntity; } }
		public new IntermediateEntity _getIntermediateEntity() { return __intermediateEntity; }
		
		//Fields		
			
		//Navigation Properties
		public ICollection<projectNS.Item> Items 
		{	
			get { return _intermediateEntity.Items.EntityCollection; }
		}		
		public Customer() : this(new intermediateNS.Customer())
		{
		}
			
		public Customer(intermediateNS.Customer intermediateEntity) : base(intermediateEntity._base) 		{
			__intermediateEntity = intermediateEntity;
			__intermediateEntity._entityView = this;
		}		
	}
}
	
namespace Debugging.Models.Intermediate
{
	public class Customer : IntermediateEntity<projectNS.Customer, L2SNS.Customer>
	{		
		private intermediateNS.User __base;	
		public intermediateNS.User _base { get { return __base; } }	
			
		//Fields				
		public long Id 
		{	
			get { return __base.Id; }
			set { __base.Id = value; }
		}


		//Navigation Properties
		public IntermediateEntityCollection<projectNS.Customer, projectNS.Item, intermediateNS.Customer, intermediateNS.Item, L2SNS.Customer, L2SNS.Item> _items;
		public IntermediateEntityCollection<projectNS.Customer, projectNS.Item, intermediateNS.Customer, intermediateNS.Item, L2SNS.Customer, L2SNS.Item> Items 
		{	
			get { return _items; }		
		}				
		
		//Inherited Navigation Properties
						
		public Customer()
		{
			__base = new intermediateNS.User();
			__tableEntity = new L2SNS.Customer();
			__tableEntity.User = __base._tableEntity;
			initFields();
		}
			
		public Customer(L2SNS.Customer tableEntity, intermediateNS.User baseclass)
		{
			__base = baseclass;
			__tableEntity = tableEntity;
			__tableEntity.User = __base._tableEntity;
			initFields();
		}

		private void initFields()
		{
			_items = new IntermediateEntityCollection<projectNS.Customer, projectNS.Item, intermediateNS.Customer, intermediateNS.Item, L2SNS.Customer, L2SNS.Item>(this, __item => __item._customer);
		}
	}
}
	
namespace Debugging.Models.L2S
{
	partial class Customer : ITableEntity<intermediateNS.Customer>
	{
        public intermediateNS.Customer _intermediateEntity { get; set; }
	
		public IntermediateEntity _getIntermediateEntity()
		{
			return _intermediateEntity;
		}		
			
		public void _setIntermediateEntity(IntermediateEntity intermediateEntity)
		{
			_intermediateEntity = intermediateEntity as intermediateNS.Customer;
		}
	}
}

